<?php

####### Bootstrap
require 'core/ClassLoader.php';

$loader = new ClassLoader();
$loader->registerDir(substr(dirname(__FILE__), 0, -4) . '/core');
$loader->registerDir(substr(dirname(__FILE__), 0, -4) . '/models');
$loader->register();

####### Application
class App extends CApplication
{
	public function getRootDir()
	{
		return substr(dirname(__FILE__), 0, -4);
	}
	
	protected function registerRoutes()
	{
		return array(
			'/'	=> array('controller' => 'home', 'action' => 'index'),
			'/home/:action' => array('controller' => 'home'),
			'/demo/:action' => array('controller' => 'demo'),
			'/couch/:action' => array('controller' => 'couch')
		);
	}
	
	protected function configure()
	{
		$dsn = 'mysql:dbname=' . APP_DB_NAME . ';host=' . APP_DB_HOST;
		
		$this->db_manager->connect('master', array(
			'dsn'	=> $dsn,
			'user'	=> APP_DB_USER,
			'password' => APP_DB_PASSWORD,
		));
	}
	
}